package Server.Model.Base;

import java.lang.ref.WeakReference;

import org.json.JSONObject;

import Server.Agent.GameAgent;
import Server.Model.Hall.dthall;

public class ReceiveMessage implements INotifierBase{
	
	private WeakReference<GameAgent> agent;
	private String msg;
	
	public ReceiveMessage(String message,GameAgent agent){
		msg = message;
		this.agent = new WeakReference<GameAgent>(agent);
	}
	@Override
	public void run() {
		run(this);
	}
	public static void  run(ReceiveMessage msg){
		JSONObject json = new JSONObject(msg.msg);
		//System.out.println(json.get("command"));
		GameAgent agent = msg.agent.get();
		if (agent != null) {
			dthall.getInstance().OnRecv(agent,json);
		}
	}
}
